<?php
	class blog extends controller {
		function __construct()
		{
			parent::__construct();
			$this->load("views");
		}
		function index ()
		{
			$this->posts();
		}
		function posts()
		{
			$data = $this->db->select("id,title,timestamp,slug,content")->from("blog")->where(array("published"=>"1"))->limit(5)->get();
			$this->views->load("blog_posts",array('posts'=>$data));
		}
		function add()
		{
			if ($_POST)
			$this->views->load("blog_add");
		}
		
		
		
		private function install()
		{
			$this->db->create("blog")->columns(array(
				'id' => array("INTEGER","PRIMARY KEY"),
				'title' => array("CHAR(255)"),
				'timestamp' => array("INTEGER"),
				'slug' => array("CHAR(255)","UNIQUE"),
				'content' => array("TEXT"),
				'published' => array("INTEGER")
			))->exec();
		}
	}
?>